package cn.dankal.flyaudio.dialog;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import cn.dankal.flyaudio.R;
import razerdp.basepopup.BasePopupWindow;

public class ShareDialog extends BasePopupWindow implements View.OnClickListener {

    private View rootView;
    private Window window;
    private OnShareListener listener;

    public ShareDialog(Context context) {
        super(context);
    }

    @Override
    public void onViewCreated(View contentView) {
        super.onViewCreated(contentView);
        getContentView().findViewById(R.id.ll_share_wechat).setOnClickListener(this);
        getContentView().findViewById(R.id.ll_share_wechat_circle).setOnClickListener(this);
        getContentView().findViewById(R.id.ll_share_app).setOnClickListener(this);
        getContentView().findViewById(R.id.iv_close).setOnClickListener(this);
    }

    public ShareDialog setOnShareListener(OnShareListener listener) {
        this.listener = listener;
        return this;
    }


    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id) {
            case R.id.iv_close:
                dismiss();
                break;
            case R.id.ll_share_wechat:
                if (listener != null) {
                    dismiss();
                    listener.wechatShare();
                }
                break;
            case R.id.ll_share_wechat_circle:
                if (listener != null) {
                    dismiss();
                    listener.wechatCircleShare();
                }
                break;
            case R.id.ll_share_app:
                if (listener != null) {
                    dismiss();
                    listener.appShare();
                }
                break;
        }
    }

    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.dialog_share_1);
    }

    public interface OnShareListener {

        void wechatShare();

        void wechatCircleShare();

        void appShare();
    }
}